{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "ImportError",
     "evalue": "attempted relative import with no known parent package",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mImportError\u001b[0m                               Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[3], line 2\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;66;03m# DMF+AIR\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m rss\n\u001b[0;32m      4\u001b[0m parameters \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m      5\u001b[0m net_list \u001b[38;5;241m=\u001b[39m []\n",
      "\u001b[1;31mImportError\u001b[0m: attempted relative import with no known parent package"
     ]
    }
   ],
   "source": [
    "# DMF+AIR\n",
    "import rss\n",
    "\n",
    "parameters = {}\n",
    "net_list = []\n",
    "net_list.append({'net_name':'DMF','sizes':[256,256,256]})\n",
    "gpu_id = 0\n",
    "\n",
    "parameters['net_p'] = {'gpu_id':gpu_id,'net_name':'composition','net_list':net_list}\n",
    "parameters['data_p'] = {'data_shape':(256,256),'random_rate':0.5,\n",
    "                        'pre_full':True,'mask_type':'img','data_path':'./data/img/man.bmp','data_type':'gray_img', 'mask_path': './data/mask/mask.png'}\n",
    "parameters['train_p'] = {'train_epoch':2000}\n",
    "parameters['show_p'] = {'show_type':'gray_img','show_content':'original'}\n",
    "grop_reg = {'reg_name':'GroupReg','coef':1e-2,\n",
    "                       'group_para':{'n_clusters':22,'metric':'cosine','reg_mode':'single'},\n",
    "                       'each_reg_name':'INRR','start_epoch':100,'gpu_id':gpu_id,'w0_initial':1.,\n",
    "                       'x_trans':'patch','stride': 13,'patch_size':16,'search_epoch':1e2,'filter_type':None,'sigma':1e0,'lap_k':3}\n",
    "tv_reg = {'reg_name': 'TV', 'coef':1e-3,'p_norm': 1}\n",
    "huber_tv_reg = {'reg_name': 'TV', 'coef':1e-1,'lap_mode':'Huber','huber_delta':0.1}\n",
    "wtv_reg = {'reg_name': 'WTV', 'coef':1e-2}\n",
    "inrr_reg = {'reg_name':'MultiReg','reg_list':[{'reg_name':'INRR','coef':1e-2,'n':256,'mode':0,'w0_initial':1.,'lap_k':1},\n",
    "                                              {'reg_name':'INRR','coef':1e-2,'n':256,'mode':1,'w0_initial':1.,'lap_k':1}]}\n",
    "huber_reg = {'reg_name':'MultiReg','reg_list':[{'reg_name':'INRR','coef':1e-2,'n':256,'mode':0,'w0_initial':1.,'lap_k':1,'lap_mode':'Huber','huber_delta':0.1},\n",
    "                                              {'reg_name':'INRR','coef':1e-2,'n':256,'mode':1,'w0_initial':1.,'lap_k':1,'lap_mode':'Huber','huber_delta':0.1}]}\n",
    "logcosh_reg = {'reg_name':'MultiReg','reg_list':[{'reg_name':'INRR','coef':1e-2,'n':256,'mode':0,'w0_initial':1.,'lap_k':1,'lap_mode':'logcosh','huber_delta':0.3},\n",
    "                                              {'reg_name':'INRR','coef':1e-2,'n':256,'mode':1,'w0_initial':1.,'lap_k':1,'lap_mode':'logcosh','huber_delta':0.3}]}\n",
    "quantile_reg = {'reg_name':'MultiReg','reg_list':[{'reg_name':'INRR','coef':1e-2,'n':256,'mode':0,'w0_initial':1.,'lap_k':1,'lap_mode':'quantile','quantile_q':0.5},\n",
    "                                              {'reg_name':'INRR','coef':1e-2,'n':256,'mode':1,'w0_initial':1.,'lap_k':1,'lap_mode':'quantile','quantile_q':0.5}]}\n",
    "huber_grop_reg = {'reg_name':'GroupReg','coef':1e-2,\n",
    "                       'group_para':{'n_clusters':22,'metric':'cosine','reg_mode':'single'},\n",
    "                       'each_reg_name':'INRR','start_epoch':100,'gpu_id':gpu_id,'w0_initial':1.,\n",
    "                       'x_trans':'patch','stride': 13,'patch_size':16,'search_epoch':1e2,'filter_type':None,'sigma':1e0,'lap_k':1,'lap_mode':'Huber','huber_delta':0.1}\n",
    "air_reg = {'reg_name':'MultiReg','reg_list':[{'reg_name':'AIR','coef':1e-1,'n':256,'mode':0},{'reg_name':'AIR','coef':1e-1,'n':256,'mode':1}]}\n",
    "parameters['reg_p'] = air_reg\n",
    "#parameters['reg_p'] = {'reg_name':'MultiReg','reg_list':[{'reg_name':'INRR','coef':1e-2,'n':256,'mode':0},{'reg_name':'INRR','coef':1e-2,'n':256,'mode':1}]}\n",
    "# grop_reg = {'reg_name':'GroupReg','coef':1e-2,\n",
    "#                        'group_para':{'n_clusters':22,'metric':'cosine','reg_mode':'single'},\n",
    "#                        'each_reg_name':'INRR','start_epoch':100,'gpu_id':gpu_id,'w0_initial':5.,\n",
    "#                        'x_trans':'patch','stride': 4,'patch_size':8,'search_epoch':1e6,'filter_type':'gaussian','sigma':1}\n",
    "parameters['opt_p'] = {'reg': {'opt_name': 'Adam', 'lr': 1e-3, 'weight_decay': 0}}\n",
    "rssnet = rss.rssnet(parameters)\n",
    "\n",
    "rssnet.show()\n",
    "rssnet.show_p['show_content'] = 'recovered'\n",
    "for i in range(10):\n",
    "    rssnet.train()\n",
    "    rssnet.show()\n",
    "    \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
